package com.dingwei.superiordiary.adapter.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.app.MyApplication;
import com.dingwei.superiordiary.bean.CollectListBean;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.utils.MathUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by lihao on 2018/1/11.
 */

public class MyCollectAdapter extends RecyclerArrayAdapter<CollectListBean.DataBean> {
    public MyCollectAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyCollectHolder(parent);
    }


    class MyCollectHolder extends BaseViewHolder<CollectListBean.DataBean> {


        @Bind(R.id.tv_delete)
        TextView tvDelete;
        @Bind(R.id.rowBG)
        LinearLayout rowBG;
        @Bind(R.id.img)
        ImageView img;
        @Bind(R.id.tv_title)
        TextView tvTitle;
        @Bind(R.id.tv_attribute)
        TextView tvAttribute;
        @Bind(R.id.tv_price)
        TextView tvPrice;
        @Bind(R.id.rowFG)
        LinearLayout rowFG;

        public MyCollectHolder(ViewGroup parent) {
            super(parent, R.layout.item_my_collect);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void setData(CollectListBean.DataBean data) {
            super.setData(data);
            tvTitle.setText(data.name);
            tvPrice.setText("￥"+ MathUtil.trimShu(data.price+""));
            Glide.with(BaseActivity.context)
                    .load(data.icon)
                    .apply(MyApplication.options)
                    .into(img);
        }
    }
}
